//
//  YaoWenCell.m
//  PCAForWar
//
//  Created by dllo on 16/1/24.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "YaoWenCell.h"
#import "ModelForYaoWen.h"
#import "UIImageView+WebCache.h"
#import <DKNightVersion.h>

@implementation YaoWenCell

- (void)dealloc{
    
    [_labelTitle release];
    [_labelGaiYao release];
    [_imageViewLeft release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        [self createSubView];
        
        [self Night];
    }
    return self;
}

#pragma mark 夜间模式
- (void)Night {
    
    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"夜间模式"]) {
        
        [DKNightVersionManager nightFalling];
        
    } else {
        
        [DKNightVersionManager dawnComing];
    }
    
    self.labelTitle.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    
    self.labelGaiYao.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
}

- (void)createSubView {
    
    self.imageViewLeft = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imageViewLeft];
    
    self.labelTitle = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelTitle];
    
    self.labelGaiYao = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelGaiYao];
    
    self.labelGaiYao.numberOfLines = 0;
    self.labelGaiYao.font = [UIFont boldSystemFontOfSize:14];
    
    [_imageViewLeft release];
    [_labelTitle release];
    [_labelGaiYao release];
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    self.imageViewLeft.frame =CGRectMake(10, 10, self.frame.size.width / 4, self.frame.size.height - 20);
    
    self.labelTitle.frame = CGRectMake(20 + self.frame.size.width / 4, 10, self.frame.size.width - 30 - self.frame.size.width / 4, (self.frame.size.height - 30)/2);
    
    self.labelGaiYao.frame = CGRectMake(20 + self.frame.size.width / 4, 20 + (self.frame.size.height - 30)/2 , self.frame.size.width - 30 - self.frame.size.width / 4, (self.frame.size.height - 30)/2);
    
    
}

- (void)passModel:(ModelForYaoWen *)model {
    
    self.labelTitle.text = model.Title;
    self.labelGaiYao.text = model.NewsSummary;
    
    [self.imageViewLeft sd_setImageWithURL:[NSURL URLWithString:model.PicUrl] placeholderImage:[UIImage imageNamed:@"jiazai.png"]];
    
}




















- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
